<!DOCTYPE html>
<html>
<head>
    <script>if (window !== top) top.location.replace(location.href);</script>
    <meta charset="utf-8"/>
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
    <link href="../../assets/images/favicon.ico" rel="icon">
    <title>用户登录-laopifu</title>
    <link rel="stylesheet" href="../../assets/libs/layui/css/layui.css"/>
    <link rel="stylesheet" href="../../assets/module/admin.css">
    <!--[if lt IE 9]>
    <script src="https://oss.maxcdn.com/html5shiv/3.7.3/html5shiv.min.js"></script>
    <script src="https://oss.maxcdn.com/respond/1.4.2/respond.min.js"></script>
    <![endif]-->
    <style>
        body {
            background-image: url("../../assets/images/loginbg.png");
            background-repeat: no-repeat;
            background-size: cover;
            min-height: 100vh;
        }

        body:before {
            content: "";
            background-color: rgba(0, 0, 0, .2);
            position: fixed;
            top: 0;
            left: 0;
            right: 0;
            bottom: 0;
        }
    </style>
</head>
<body>
<div class="login-wrapper layui-anim layui-anim-scale layui-hide">
    <div class="login-top">
        <span>Laopifu后台登录</span>
        <span class="bg1"></span>
        <span class="bg2"></span>
    </div>
    <form class="layui-form">
        <div class="layui-form-item layui-input-icon-group" style="border-bottom: 1px solid #dae1e6;">
            <i class="layui-icon layui-icon-username"></i>
            <input class="layui-input" name="account" placeholder="请输入登录账号" autocomplete="off"
                   lay-verType="tips" lay-verify="required" required/>
        </div>
        <div class="layui-form-item layui-input-icon-group" style="border-bottom: 1px solid #dae1e6;">
            <i class="layui-icon layui-icon-password"></i>
            <input class="layui-input" name="password" placeholder="请输入登录密码" type="password"
                   lay-verType="tips" lay-verify="required" required/>
        </div>
<!--        <div class="layui-form-item layui-input-icon-group login-captcha-group">-->
<!--            <i class="layui-icon layui-icon-auz"></i>-->
<!--            <input class="layui-input" name="code" placeholder="请输入验证码" autocomplete="off"-->
<!--                   lay-verType="tips" lay-verify="required" required/>-->
<!--            <img class="login-captcha" alt=""/>-->
<!--        </div>-->
        <div class="layui-form-item">
            <input type="checkbox" name="remember" title="记住密码" lay-skin="primary" checked>
            <a href="reg.html" class="layui-link pull-right">注册账号</a>
        </div>
        <div class="layui-form-item">
            <button class="layui-btn layui-btn-fluid" lay-filter="loginSubmit" lay-submit>登录</button>
        </div>
        <div class="layui-form-item login-oauth-group text-center layui-hide">
            <a href="javascript:;"><i class="layui-icon layui-icon-login-qq" style="color:#3492ed;"></i></a>&emsp;
            <a href="javascript:;"><i class="layui-icon layui-icon-login-wechat" style="color:#4daf29;"></i></a>&emsp;
            <a href="javascript:;"><i class="layui-icon layui-icon-login-weibo" style="color:#CF1900;"></i></a>
        </div>
    </form>
</div>
<div class="login-copyright">copyright © 2020 laopifu.vip all rights reserved.</div>

<!-- js部分 -->
<script type="text/javascript" src="../../assets/libs/layui/layui.js"></script>
<script>
    layui.config({
        base: '../../assets/module/'
    }).use(['layer', 'form', 'setter', 'admin'], function () {
        var $ = layui.jquery;
        var layer = layui.layer;
        var form = layui.form;
        var setter = layui.setter;
        $('.login-wrapper').removeClass('layui-hide');
        function getQueryVariable(variable)
        {
            var query = window.location.search.substring(1);
            var vars = query.split("&");
            for (var i=0;i<vars.length;i++) {
                var pair = vars[i].split("=");
                if(pair[0] == variable){return pair[1];}
            }
            return(false);
        }
        if(!getQueryVariable('code')){
            // $.ajax({
            //     url:setter.baseServer+'/login/getWxCode',
            //     type: 'get',
            //     dataType: 'JSON',
            //     success: function (res) {
            //         if (200 === res.code) {
            //             location.replace(res.data.url);
            //         } else {
            //             layer.msg(res.msg || '登录失败', {icon: 5});
            //         }
            //     }
            // });
        }else{
            $.ajax({
                url:setter.baseServer+'/login/xnLogin',
                // url:setter.baseServer+'/login/getLoginUser',
                type: 'get',
                data:{'code':getQueryVariable('code')},
                dataType: 'JSON',
                success: function (res) {
                    if (200 === res.code) {
                        var token={'access_token':res.data.token,'token_type': "Bearer"}
                        setter.putToken(token);
                        layer.msg(res.msg, {icon: 1, time: 1000}, function () {
                            location.replace('../../');
                        });
                    }
                }
            });
        }
    });
</script>
</body>
</html>
